<!--  -->
<template>
  <el-image
    class="ik-image-tag"
    style="width: 40px; height: 40px"
    :src="imageUrl"
    :preview-src-list="previewList"
  />
</template>
<script>
import { getSrc } from '@/utils/ik/oss/oss.js'
export default {
  name: 'IkTableImageOssTag',
  components: {},
  props: {
    value: {
      type: String,
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    },
    code: {
      type: String,
      default: ''
    },
    name: {
      type: String,
      default: ''
    },
    defaultValue: {
      type: String,
      default: ''
    },
    fileType: {
      type: Array,
      default: () => []
    },
    tips: {
      type: String,
      default: '6'
    },
    require: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      url: this.$store.getters['setting/getUrl'],
      token: this.$store.getters['user/getToken'],
      urlfile: require('@/assets/tableimg/file.png'),
      imageUrl: '',
      previewList: [],
      val: ''
    }
  },
  computed: {
  },
  watch: {
    value: {
      handler(value, oldValue) {
        if (value !== null && value !== '') {
          this.val = value
        } else {
          this.val = this.defaultValue
        }
        this.gets()
      },
      immediate: true
    },
    val: {
      handler(value, oldValue) {
        this.click(value)
      }
    }
  },
  created() {
    this.gets()
  },
  mounted() {
  },
  methods: {
    gets() {
      if (this.val) {
        this.imageUrl = getSrc("", this.val) // 可访问的链接
        this.previewList = [this.imageUrl]
      }
    }
  }
}
</script>
<style lang='scss' scoped>
.ik-image-tag {
  cursor: pointer;
  overflow: visible;
}
</style>
